package com.wjm.blog.common.validation;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

/**
 * 枚举校验注解
 *
 * @author: Ailos
 * @date: 2020/7/24 9:32
 * @version: 1.0
 */
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Constraint(validatedBy = {EnumValidatorForString.class})
public @interface EnumValidForString {

    String message() default "";

    // 作用参考@Validated和@Valid的区别
    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    /**
     * 目标枚举类
     */
    Class<?> target() default Class.class;

    /**
     * 定义通过code获取枚举值的方法
     */
    String getByCode() default "getByCode";

    /**
     * 是否忽略空值
     */
    boolean ignoreEmpty() default true;
}
